package com.five.years.common.exception;

import com.five.years.common.SystemCode;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author : qinhuajun
 * @Date :2020-03-06
 */
@Data
public class BusinessException extends RuntimeException {

    private String errCode;
    private String message;

    public BusinessException(String errCode, String message) {
        super(message);
        this.errCode = errCode;
        this.message = message;
    }

    public BusinessException(SystemCode systemCode) {
        this.errCode = systemCode.getCode();
        this.message = systemCode.getMessage();
    }

    public BusinessException(String message) {
        super(message);
        this.errCode = SystemCode.FAIL.getCode();
        this.message = message;
    }

    public static String throwStringException(String msg) {
        throw new BusinessException(msg);
    }

    public static Integer throwIntegerException(String msg) {
        throw new BusinessException(msg);
    }

    public static BigDecimal throwBigDecimalException(String msg) {
        throw new BusinessException(msg);
    }
}
